﻿using IniReadWrite;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace VisionRoc.Core
{
    public class SetRectangle1
    {
        public string Rectangle1Path;
        public SetRectangle1(string _Path)
        {
            if (!Directory.Exists(_Path))
            {
                Directory.CreateDirectory(_Path);
            }

            Rectangle1Path = _Path + "\\Rectangle1.ini";
            if (File.Exists(Rectangle1Path))
            {
                ReadRectangle1Parameter();
            }
        }


        [Browsable(true), Description("矩形1：Row1参数"), Category("矩形1区域参数"), ReadOnly(false)]
        public double Row1 { get; set; }

        [Browsable(true), Description("矩形1：Col1参数"), Category("矩形1区域参数"), ReadOnly(false)]
        public double Col1 { get; set; }

        [Browsable(true), Description("矩形1：Row2参数"), Category("矩形1区域参数"), ReadOnly(false)]
        public double Row2 { get; set; }

        [Browsable(true), Description("矩形1：Col1参数"), Category("矩形1区域参数"), ReadOnly(false)]
        public double Col2 { get; set; }


        /// <summary>
        /// 保存矩形1参数
        /// </summary>
        public void WriteRectangle1Parameter()
        {
            IniAPI.INIWriteValue(Rectangle1Path, "Rectangle1Parameter", "DrawRow", Row1.ToString());
            IniAPI.INIWriteValue(Rectangle1Path, "Rectangle1Parameter", "DrawCol", Col1.ToString());
            IniAPI.INIWriteValue(Rectangle1Path, "Rectangle1Parameter", "DrawPhi", Row2.ToString());
            IniAPI.INIWriteValue(Rectangle1Path, "Rectangle1Parameter", "DrawLength1", Col2.ToString());
        }



        /// <summary>
        /// 读取矩形1参数
        /// </summary>
        public void ReadRectangle1Parameter()
        {
            try
            {
                Row1 = Convert.ToDouble(IniAPI.INIGetStringValue(Rectangle1Path, "Rectangle1Parameter", "DrawRow", "0"));
                Col1 = Convert.ToDouble(IniAPI.INIGetStringValue(Rectangle1Path, "Rectangle1Parameter", "DrawCol", "0"));
                Row2 = Convert.ToDouble(IniAPI.INIGetStringValue(Rectangle1Path, "Rectangle1Parameter", "DrawPhi", "0"));
                Col2 = Convert.ToDouble(IniAPI.INIGetStringValue(Rectangle1Path, "Rectangle1Parameter", "DrawLength1", "0"));
            }
            catch { }

        }
    }
}
